package PTA.Mianxiangduixiang.ex40;

import java.util.Scanner;
class Student{
    private String name;
    private int age;
Student(String name,int age){
    this.name=name;
    this.age=age;
}
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age<=6){
            this.age=7;
        }else{
            this.age=age;
        }

    }
    Student(){
        age=7;
        name="无名";
        System.out.println("无参构造方法");
    }
    public void display(){
        System.out.println("name:"+name+",age:"+age);
    }
}
public class ex40 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Student s = new Student();
s.display();
        s.setName(sc.next());
        s.setAge(sc.nextInt());
        s.display();

    }
}
